package com.base.bean;

import javax.annotation.PostConstruct;
import javax.faces.bean.ManagedBean;
import javax.faces.bean.ViewScoped;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

import com.base.domain.Socio;
import com.base.security.NavigationPages;
import com.base.service.SocioService;

@Component
@ManagedBean
@ViewScoped
public class SocioBean {

	private Socio socio;
	
	@Autowired
	private SocioService socioService;

	@PostConstruct
	public void init() {
		Socio socio = new Socio();
		
		socio.setActive(Boolean.TRUE);
		setSocio(socio);
	}

	public String guardar() {
		Socio socio = getSocio();
		socioService.save(socio);
		init();
		return NavigationPages.INDEX_PAGE;
	}
	
	public String cancelar() {
		init();
		return NavigationPages.INDEX_PAGE;
	}

	public Socio getSocio() {
		return socio;
	}

	public void setSocio(Socio socio) {
		this.socio = socio;
	}
		
}